package org.batatasframework.support.database.values;

import java.util.List;

import org.batatasframework.support.database.sql.field.FieldElement;
import org.batatasframework.support.database.sql.field.MultipleSelectFragment;


//TODO 这个对象应该不变
public class FormatValueHolder extends AbstractMultipleValueHolder{

	private final String formatString;
	
	public FormatValueHolder(MultipleSelectFragment field, String formatString, List<? extends FieldElement> relations) {
		super(field, relations);
		this.formatString = formatString;
	}

	@Override
	protected FieldValue read(Object[] args) throws Exception {
		return new FormatValue(args);
	}

	@Override
	public StatisticsTotal createStatistics() {
		return null;
	}
	
	class FormatValue extends AbstractValue<Object[]>{
		
		public FormatValue(Object[] args) {
			super(args);
		}

		@Override
		public Object targetValue() {
			return String.format(formatString, value);
		}
	}

}
